/**
 * Copyright 2016 Qiyi Inc. All rights reserved.
 *
 * @file:   StatisticSty2.Util.js
 * @path:   js-src/StatisticSty2/
 * @desc:
 * @author: zhang@qiyi.com
 * @date:   2016-03-28
 */
qui(function(require, exports, module){

    StatisticSty2.Util = $.extend(true, {}, {

        programMinutes: function (v, o, r) {
            var duration = v;
            var darArr = [];
            darArr.push(duration % 60);
            duration = ( duration - duration % 60) / 60;
            darArr.push(duration % 60);
            duration = ( duration - duration % 60) / 60;
            darArr.push(duration);
//                    duration = ( duration - duration % 24) / 24;
//                    if (duration > 0) {
//                        darArr.push(duration);
//                    }
            var retValue = "";
            switch (darArr.length) {
                case 3:
                    retValue += darArr[2] <= 0 ? "" : darArr[2] + "时";
                case 2:
                    retValue += darArr[1] <= 0 ? "" : darArr[1] + "分";
                case 1:
                    retValue += darArr[0] <= 0 ? "" : darArr[0] + "秒";
                    break;
            }
            if(retValue.length == 0){
                retValue = "0秒";
            }
            return retValue;
        },
        buildTH: function (dataArr) {
            var retValue = [];
            $.each(dataArr, function (i, element) {
                retValue.push("<td>" + element + "</td>");
            });
            return "<tr>" + retValue.join("") + "</tr>";
        },

        buildTD: function (object, keyArr) {
            var retValue = [];
            $.each(keyArr, function (index, element) {
                var configData = StatisticSty2.Config.TABLE_COLMODEL_CONFIG[element]
                if (configData.formatter != null) {
                    retValue.push("<td>" + configData.formatter(object[configData.name], null, object) + "</td>");
                } else {
                    retValue.push("<td>" + object[configData.name] + "</td>");
                }
            });
            return "<tr>" + retValue.join("") + "</tr>";
        }
	});

});
